package pl.edu.mimuw.irs.rcp.controller.handler;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.handlers.HandlerUtil;

import pl.edu.mimuw.irs.core.model.design.IRSWorkflow;
import pl.edu.mimuw.irs.rcp.controller.editor.IRSWorkflowEditor;
import pl.edu.mimuw.irs.rcp.controller.editor.IRSWorkflowEditorInput;

/**
 * @author Jakub Rauch
 * Created on: 2009-05-25
 */
public class NewWorkflowHandler extends AbstractHandler {

	@Override
	public Object execute(ExecutionEvent event) throws ExecutionException {
		try {
			IRSWorkflowEditorInput input = new IRSWorkflowEditorInput();
			input.setIrsWorkflow(new IRSWorkflow());
			input.getIrsWorkflow().createSampleModel();
			HandlerUtil.getActiveWorkbenchWindow(event).getActivePage()
					.openEditor(input, IRSWorkflowEditor.ID);
		} catch (PartInitException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return null;
	}

	// *** Attributes

	// *** Methods
}
